class CardForSave extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            cardVendor : -1,
            commCode : ""
        };
    }

    componentDidMount(){
        //postJson("")
    }

    getBody(){
        if(this.state.cardVendor === -1)
            return null;
        else if(this.state.cardVendor === 0)
            return <GS_ICCardForSave ref="cardForSave" commCode={this.state.commCode}/>
        else if(this.state.cardVendor === 10)
            return <LK_ICCardForSave ref="cardForSave" commCode={this.state.commCode}/>
        else if(this.state.cardVendor === 11)
            return <IDForSave ref="cardForSave" commCode={this.state.commCode}/>
    }

    onChangeComm(comm){
        postJson("/comm/getCommInfo.x", {commInfo : comm}, (data) => {
            this.setState({commCode : comm,cardVendor : data.data.commInfo.cardVendor});
        });
    }

    render(){
        return (
            <Frame header="新增IC卡" headerBtns={
                [
                    <Form frameStyle={{display:"inline"}} style={{display:"inline",marginLeft:5}}>
                        <LayuiCommSelect size="sm" mask={['building', 'unit', 'floor', 'room']} ref="commSelect"
                                         value={this.state.currentComm} onChangeComm={(comm) => this.onChangeComm(comm)}/>
                    </Form>,
                    <HeaderBtn onClick={() => {this.refs.cardForSave.downloadPlugins()}}><i className="fa fa-download"/>&nbsp;插件下载</HeaderBtn>
                ]}>
                {
                    this.getBody()
                }
            </Frame>
        )

    }

}

ReactDOM.render(<CardForSave/>,document.getElementById("forSaveCard"));